package com.uno.mapsearch.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import de.micromata.opengis.kml.v_2_2_0.AltitudeMode;
import de.micromata.opengis.kml.v_2_2_0.Document;
import de.micromata.opengis.kml.v_2_2_0.Kml;
import de.micromata.opengis.kml.v_2_2_0.Point;

@Path("/placements")
public class MapSearchRestService {

	@GET
	@Produces(MediaType.APPLICATION_XML)
	public Kml getResourcesKML() {
		final Kml kml = new Kml();
		Document document = kml.createAndSetDocument().withName("MapSearch Resources");
		Point point = document.createAndAddPlacemark()
				.withName("Manhattan Skyline").createAndSetPoint();
		configurePoint(point, -73.9915788333333, 40.7084988333333, 0);

		point = document.createAndAddPlacemark().withName("Lower East Side")
				.createAndSetPoint();
		configurePoint(point, -73.9925443333333, 40.7102921666667, 0);

		return kml;
	}

	private static void configurePoint(Point point, double longitude,
			double latitude, double altitude) {
		point.addToCoordinates(longitude, latitude, altitude);
		point.setExtrude(true);
		point.setAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND);

	}
	
		
}
